﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Entities;

namespace Presentation
{
    public partial class WithdrawMain : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        LogsEntity log = new LogsEntity();
        AccountsEntity aC = new AccountsEntity();
        CustomerBLL cus = new CustomerBLL();
        MoneysEntity mn = new MoneysEntity();

        Decimal amount;

        protected void Button1_Click(object sender, EventArgs e)
        {
            int accID = int.Parse(Session["AccountID"].ToString());
            string cardNo = Session["CardNo"].ToString();
            amount = 500000;
            Decimal monyeATM = cus.GetMoney(1);
            Decimal blacance = cus.GetBalance(accID);
            if ((blacance > amount) && (monyeATM > amount))
            {
                cus.Withdraw(amount, accID, cardNo);
                Response.Redirect("WithdrawPrintReceipt.aspx");
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "alert", "alert('Withdraw fail, because blacance account or monye in ATM not enough!');", true);
            }

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            int AccID = int.Parse(Session["AccountID"].ToString());
            string CardNo = Session["CardNo"].ToString();
            amount = 1000000;
            Decimal monyeATM = cus.GetMoney(1);
            Decimal blacance = cus.GetBalance(AccID);
            if ((blacance > amount) && (monyeATM > amount))
            {
                cus.Withdraw(amount, AccID, CardNo);
                Response.Redirect("WithdrawPrintReceipt.aspx");
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "alert", "alert('Withdraw fail, because blacance account or monye in ATM not enough!');", true);
            }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            int AccID = int.Parse(Session["AccountID"].ToString());
            string CardNo = Session["CardNo"].ToString();
            amount = 2000000;
            Decimal monyeATM = cus.GetMoney(1);
            Decimal blacance = cus.GetBalance(AccID);
            if ((blacance > amount) && (monyeATM > amount))
            {
                cus.Withdraw(amount, AccID, CardNo);
                Response.Redirect("WithdrawPrintReceipt.aspx");
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "alert", "alert('Withdraw fail, because blacance account or monye in ATM not enough!');", true);
            }
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            int AccID = int.Parse(Session["AccountID"].ToString());
            string CardNo = Session["CardNo"].ToString();
            amount = 2500000;
            Decimal blacance = cus.GetBalance(AccID);
            Decimal monyeATM = cus.GetMoney(1);
            if ((blacance > amount) && (monyeATM > amount))
            {
                cus.Withdraw(amount, AccID, CardNo);
                Response.Redirect("WithdrawPrintReceipt.aspx");
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "alert", "alert('Withdraw fail, because blacance account or monye in ATM not enough!');", true);
            }
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            int AccID = int.Parse(Session["AccountID"].ToString());
            string CardNo = Session["CardNo"].ToString();
            amount = 3000000;
            Decimal blacance = cus.GetBalance(AccID);
            Decimal monyeATM = cus.GetMoney(1);
            if ((blacance > amount) && (monyeATM > amount))
            {
                cus.Withdraw(amount, AccID, CardNo);
                Response.Redirect("WithdrawPrintReceipt.aspx");
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "alert", "alert('Withdraw fail, because blacance account or monye in ATM not enough!');", true);
            }
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            Response.Redirect("WithdrawEnterOther.aspx");
        }
    }
}